package screens 
{
	import Buttons.Tool;
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Andy Wolff
	 */
	public class ToolsTabs extends MovieClip
	{
		[Embed(source = '../images/Buttons/tabs1.png')] private var tab1IMG:Class;
		
		public var tab1:MovieClip, tab2:PlayNoteTab, tab3:InstrumentsTab;
		
		//tab 1
		private var tools:Array;
		[Embed(source = '../images/Buttons/DrawNotes.png')] private var DrawNotesIMG:Class;
		[Embed(source = '../images/Buttons/Erase.png')] private var EraseIMG:Class;
		[Embed(source = '../images/Buttons/copy.png')] private var CopyIMG:Class;
		[Embed(source = '../images/Buttons/move.png')] private var MoveIMG:Class;
		[Embed(source = '../images/Buttons/pan.png')] private var PanIMG:Class;
		[Embed(source = '../images/Buttons/Selected.png')] private var SelectIMG:Class;
		
		//Tab 2
		private var notes:Array;
		
		
		private var select:int, selectMC:MovieClip;
		public function selectTool(which:int):void { select = which; selectMC.x = tools[which].x; selectMC.y = tools[which].y; }
		public function whichTool():int { return select; }
		
		public function ToolsTabs(canvas:NoteCanvas) 
		{
			super();
			tab1 = new MovieClip; tab2 = new PlayNoteTab(canvas); tab3 = new InstrumentsTab(canvas);
			tab1.addChild(new tab1IMG()); 
			
			addChild(tab1); 
			tab1Init();
			addChild(tab2); 
			addChild(tab3);
			tab1.visible = true;
			tab2.visible = false;
			tab3.visible = false;
			
			Main.center(this);
			x = 800 - width - 20;
			
			addEventListener(MouseEvent.MOUSE_DOWN, click);
		}
		
		private function click(me:MouseEvent):void {
			if (me.stageY < 35 && me.stageX < 800-tab1.width / 2) { tab1.visible = true; tab2.visible = false; tab3.visible = false; }
			else if (me.stageY < 35 && me.stageX >= 800-tab1.width / 2) { tab2.visible = true; tab1.visible = false; tab3.visible = false; }
			else if (me.stageY > height - 40) { tab3.visible = true; tab2.visible = false; tab1.visible = false; }
		}
		
		private function tab1Init():void {
			var last:MovieClip;
			var i:int = 0;
			tools = new Array(5);
			
			var DrawNotesBtn:Tool = new Tool(this,i);
			DrawNotesBtn.addChild(new DrawNotesIMG());
			Main.center2(DrawNotesBtn, width, 0);
			DrawNotesBtn.y = 40;
			tab1.addChild(DrawNotesBtn);
			last = DrawNotesBtn; 
			Tool.DRAW = i;
			tools[i] = last;
			i++;
			
			var EraseBtn:Tool = new Tool(this,i);
			EraseBtn.addChild(new EraseIMG());
			Main.center2(EraseBtn, width, 0);
			EraseBtn.y = last.y+last.height+10;
			tab1.addChild(EraseBtn);
			last = EraseBtn;
			Tool.ERASE = i;
			tools[i] = last;
			i++;
			
			var CopyBtn:Tool = new Tool(this,i);
			CopyBtn.addChild(new CopyIMG());
			Main.center2(CopyBtn, width, 0);
			CopyBtn.y = last.y+last.height+10;
			tab1.addChild(CopyBtn);
			last = CopyBtn;
			Tool.COPY = i;
			tools[i] = last;
			i++;
			
			var MoveBtn:Tool = new Tool(this,i);
			MoveBtn.addChild(new MoveIMG());
			Main.center2(MoveBtn, width, 0);
			MoveBtn.y = last.y+last.height+10;
			tab1.addChild(MoveBtn);
			last = MoveBtn;
			Tool.MOVE = i;
			tools[i] = last;
			i++;
			
			var PanBtn:Tool = new Tool(this,i);
			PanBtn.addChild(new PanIMG());
			Main.center2(PanBtn, width, 0);
			PanBtn.y = last.y+last.height+10;
			tab1.addChild(PanBtn);
			last = PanBtn;
			Tool.PAN = i;
			tools[i] = last;
			i++;
			
			selectMC = new MovieClip();
			selectMC.addChild(new SelectIMG());
			tab1.addChild(selectMC);
			
			selectTool(0);
		}
		
			
		
	}

}